Example workflow contracts ========================== The companion ``WorkingWithAModel/example_contracts/howto.m`` runs small serialization, color and progress examples without fitting a model. Publishing and installation checks ---------------------------------- ``rise.publish(source,'SaveAs',destination)`` respects the complete destination, including nested relative or absolute folders. A missing extension means PDF. The PDF, retained TeX and figure directory are delivered together; the caller's working folder is restored after success or failure. The existing temporary builder still handles compilation. Source listings preserve literal markup. Unsupported characters appear as explicit UTF-16 ``\uXXXX`` units, including both units of a surrogate pair, rather than disappearing or being replaced by different punctuation. A notice identifies this representation; the original source remains unchanged and is the source to execute. Console-control cleanup applies to console output. ``[status,diagnostic]=rise.demo()`` returns status zero only when all checks pass, and one on a caught failure. The diagnostic contains ``stage`` and ``exception``. Only figures created during the demonstration are closed. The original model and its calibration are retained. Numerical and graphics utilities -------------------------------- Polynomial serialization uses enough significant digits to retain double coefficients. Signed scientific exponents belong to the numeric literal, not polynomial subtraction. The formatter can reorder monomials; compare their powers together with the associated coefficients. ``colorspace(matrix,rgb)`` applies a real finite 3-by-3 transform. ``colorspace('hsi<-rgb',rgb)`` uses intensity equal to the arithmetic RGB mean, saturation one minus the minimum channel divided by intensity, and angular hue. Black and gray have zero saturation and hue. The inverse uses the corresponding three hue sectors. HSI and HSL have different definitions. Zero total work in ``progress_monitor`` is already complete: it creates no parallel queue or progress figure. Zero increments are accepted, while invalid indices, negative/nonfinite counts and positive work against a zero total are rejected. ``CancelButton=false`` creates no cancel control. Retained model examples ----------------------- Start the currently active installation with ``rise.startup()``. In the irreversible-investment example, ``I`` is the investment nonnegativity slack; ``I-.025*k`` is a separate stationary capital-law residual. The SGUSEA callbacks declare their computed parameter updates, use a unit multiplier when the additional shock is absent, and reject failed or inaccurate price solves. The engine checks the original steady-state equations instead of treating the returned point as imposed. No equation or calibration is changed by these callback repairs. The driver filters its fitted model. The numbered batch driver runs each script in its own function workspace and returns a structure indexed by driver name. Driver03 retains its calibrated ``m``; driver12 retains ``mest1`` and ``mest2``; other drivers retain ``mest``. A missing output is an error, so the previous driver's result cannot leak in. The recession plots request one ordinary forecast per recession and make no claim to remove an individual shock. The marginal-density example keeps complete chain results and evaluates all nine supported methods through ``mdd``. Stored ``f`` values and the supplied objective are the negative log posterior. The historical cache has no verified parameter-order metadata, so its serialized callback is never loaded. Enable sampling to use a freshly rebuilt objective and its same-run draws and bounds. New files retain numeric results, parameter names, version and model source instead of callbacks. Separately saved chains still need a verified matching contract before reuse. The sampler option is ``thinning``. The example's bounded validation uses a known Gaussian normalization with a nonzero log-kernel offset, not a fitted model likelihood. Structural VAR adapters retain the original chains, restrictions and prior arguments. Equation references use names from the supplied ordering. Plotting uses ``get(model,'endo_list(original)')`` rather than generated lag auxiliaries. Construction and prior/restriction absorption are separate from a complete replication estimate. Source configurations 1, 2, 3 and 5 retain their original Beta priors with mean 0.1 and standard deviation 0.3. A proper Beta distribution requires variance strictly below :math:`m(1-m)`; these declarations are at the improper boundary. Their numbered workflows stop before loading data, and the batch workflow reports and skips only those four configurations. Types 0, 4 and 6 and all financial-stress specifications remain available. No replacement prior is chosen, and the source factories retain the declarations for inspection. The variance-only workflow retains its three original joint Dirichlet priors and uses the constructed model in its downstream calls. The bounded companion ``retained_svar_source_priors_example(source_root)`` returns the availability mask without loading data, estimating or sampling. Bounded constructor checks do not certify a complete replication estimate. The unfinished conditional draft still requires its absent original posterior-coordinate converter and a validated simulation plan before it can report a conditional result. The retained prior-density reference helper supports uniform and no-prior groups without extra files. Other shapes name the missing original density helper and remain parked; no substitute density is inferred. The native model example uses RISE's distribution infrastructure independently. Static code inspection ---------------------- The call scanner distinguishes comments, quoted literals, doubled quotes, transpose operators and named handles. A percent sign inside a string cannot hide a later call. Unresolved dynamic or lexical references classify otherwise unreferenced names as unknown. A static unreferenced candidate is not evidence that deleting a capability is safe. Inflation targets in the bond-premium example --------------------------------------------- `Rudebusch and Swanson (2012) `_, "The Bond Premium in a DSGE Model with Long-Run Real and Nominal Risks", American Economic Journal: Macroeconomics 4(1), 2012, 105--143, and the public replication files specify an annualized log inflation target and positive target persistence. For the retained example, ``PIBAR`` and ``PISTAR`` are annualized log rates, whereas ``PI`` and ``PIAVG`` are quarterly gross rates. Thus the steady relations are :math:`\log(PI)=PIBAR/4` and :math:`PISTAR=PIBAR`. The target's contemporaneous feedback uses :math:`4\log(PIAVG)-PISTAR`. Calibration and the original shock declarations are retained. At nonzero target inflation, the reset price and price dispersion must be computed jointly with marginal cost. The numerator's continuation exponent is :math:`(1+\theta)/(\theta\eta)`. The production and wage reference values then follow their written equations; assigning the zero-inflation dispersion or markup away from zero inflation would violate those identities. ``rudebusch_inflation_target_example(source_root,annual_target)`` computes this reference state with an explicit annualized log target. It does not run estimation or a stochastic solution. Bounded tests check every written steady equilibrium/reporting identity at zero, positive and negative targets, including persistent targets and feedback. The supplied local calibration is retained; this check is not a reproduction of the paper's parameter estimation. A binding date in the affine-rate example ----------------------------------------- The separate ``howto_zlb_linear_rate`` worked example uses the original switching NK calibration with an affine level-rate policy and the existing ``occbin.paradigm`` solver. Its twenty-period scenario sets one monetary-policy innovation to -30 at date1 and every other innovation to zero. The transition probabilities do not select regimes under this constraint-driven paradigm. The native check exercises both a binding and a slack date. It verifies finite, nonnegative realized rates and the independent relation ``R=max(0,Rshadow)`` at every simulated date. The shadow rate is the affine Taylor expression evaluated with the simulated inflation and lagged rate. This checks both release and binding conditions, rather than only a regime label. The separate original log-rate and dispatch examples are retained. ``switching_zlb_level_example(tests_root)`` runs this bounded scenario from the tutorials. The affine bound is exact in rate levels; other equations use the stated first-order piecewise-linear approximation. No full nonlinear residual or stochastic-accuracy claim follows from this check. Value derivatives in the Bellman-game reference ----------------------------------------------- The retained Algorithm3 iteration passes independent unilateral best-response, Bellman-value and strategic-envelope checks at its supplied calibration. It uses discounted continuation-value derivatives in the current debt stationarity equations and separately recovers current constraint multipliers. These quantities need not coincide when a rival follows a state-dependent rule. The reference result fields ``Lambda`` and ``Mu`` report the current multipliers from entries10 and11 of ``p``, consistently with the other two reference algorithms. ``continuationM`` and ``continuationF`` report the discounted continuation-value derivative coefficients. With the stated quadratic value normalization and default factor2, these are ``2*beta*Sm`` and ``2*beta*Sf``. This reporting repair leaves the numerical policy/value iteration unchanged. History columns10 and11 are named ``continuation_m`` and ``continuation_f``. The final diagnostic is ``envelope_res`` and includes each rival's state response. A difference between a current multiplier and a continuation derivative is generally nonzero and is not an equilibrium residual. The new ``algorithm3_markov_v2/main.tex`` and matching PDF derive the current best-response equations, the strategic envelopes and the meaning of the code inputs. Historical notes remain unchanged. Use ``bellman_rival_response_example(tests_root)`` for the bounded companion. The checks concern this retained linear-quadratic example and do not establish global nonlinear-game uniqueness or equivalence of the other iterations. Both retained post-processing envelope checkers now include the rival terms. The individual fiscal reduction uses signs obtained directly from the written debt and Phillips equations; its previous hand elimination was inconsistent. These changes affect diagnostics rather than the Bellman policy iteration. The home-consumption CES endpoint --------------------------------- For positive market and home consumption and ``0